<extend name="Public/baseConf"/>
<block name="breadcrumb"> 
<div class="row wrapper border-bottom white-bg page-heading">
	    <div class="col-lg-5">
	        <h2>文档列表({$_total})
			    <small><notempty name="rightNav">
					[<volist name="rightNav" id="nav">
					<a href="{:U('index','cate_id='.$nav['id'])}">{$nav.title}</a>
						<if condition="count($rightNav) gt $i"><i class="fa fa-chevron-right"></i></if>
					</volist>
					<present name="article">：<a href="{:U('index','cate_id='.$cate_id.'&pid='.$article['id'])}">{$article.title}</a></present>
					]
				<else/>
					<empty name="position"><a class="btn btn-sm btn-danger btn-round" >全部</a>
					<else/> 
						<a class="btn btn-sm btn-white btn-round" href="{:U('article/index')}">全部</a>
					</empty>
					<foreach name="Think.config.DOCUMENT_POSITION" item="vo">
					<neq name="position" value="$key">
						<a class="btn btn-sm btn-white btn-round" href="{:U('index',array('position'=>$key))}">{$vo}</a>
					<else/>
						<label class="btn btn-sm  btn-danger btn-round" >{$vo}</label></neq>
					</foreach>
				</notempty>
				<if condition="count($model) gt 1"> 
					<empty name="model_id">
						<a class="btn btn-sm btn-danger btn-round" >全部</a>
					<else/>
						<a class="btn btn-sm btn-white btn-round" href="{:U('index',array('pid'=>$pid,'cate_id'=>$cate_id))}">全部</a>
					</empty>
					<volist name="model" id="vo">
						<neq name="model_id" value="$vo">
						<a class="btn btn-sm btn-white btn-round" href="{:U('index',array('pid'=>$pid,'cate_id'=>$cate_id,'model_id'=>$vo))}">{$vo|get_document_model='title'}</a>
						<else/>
						<a class="btn btn-sm btn-danger btn-round" >{$vo|get_document_model='title'}</a>
						</neq> 
					</volist>
				</if>
				<notempty name="groups">[ 分组：<empty name="group_id"><strong>全部</strong><else/><a href="{:U('index',array('pid'=>$pid,'cate_id'=>$cate_id))}">全部</a></empty>
					<foreach name="groups" item="vo">
					<neq name="group_id" value="$key"><a href="{:U('index',array('pid'=>$pid,'cate_id'=>$cate_id,'model_id'=>$model_id,'group_id'=>$key))}">{$vo}</a><else/><strong>{$vo}</strong></neq>&nbsp;
					</foreach>
				]</notempty>
				</small>
			
			
	        </h2>
	        <ol class="breadcrumb">
	            <li><a href="{:U('index/index')}">首页</a></li>
	            <li class="active">
	                <strong>文档列表<eq name="allow" value="0"><code>（该分类不允许发布内容）</code></eq></strong>
	            </li>
	        </ol>
	    </div>
	    <div class="col-lg-7">
            <div class="title-action">
				<span class="block pull-right">
					<div class="btn-group">
						<gt name="allow" value="0">
							<div class="btn-group">
	                            <button data-toggle="dropdown" class="btn btn-primary dropdown-toggle document_add"  <if condition="count($model) eq 1">url="{:U('article/add',array('cate_id'=>$cate_id,'pid'=>I('pid',0),'model_id'=>$model[0],'group_id'=>$group_id))}"</if>>
	                            	<i class="fa fa-pencil"></i>新 增<if condition="count($model) gt 1"><span class="caret"></span></if>
	                            </button>
		                        <if condition="count($model) gt 1">
									<ul class="dropdown-menu">
										<volist name="model" id="vo">
										<li><a href="{:U('article/add',array('cate_id'=>$cate_id,'model_id'=>$vo,'pid'=>I('pid',0),'group_id'=>$group_id))}">{$vo|get_document_model='title'}</a></li>
										</volist>
									</ul>
								</if>
	                        </div>
						<else/>
							<button class="btn btn-white disabled" ><i class="fa fa-pencil"></i>新 增
								<if condition="count($model) gt 1"><i class="btn-arrowdown"></i></if>
							</button>
						</gt>
					</div>
		            <button class="btn btn-white ajax-post" url='{:U("Article/setStatus",array("status"=>1))}'  target-form="ids">
						<i class="fa fa-flag"></i>启用
					</button>
					<button class="btn btn-white ajax-post" url='{:U("Article/setStatus",array("status"=>0))}'  target-form="ids">
						<i class="text-danger fa fa-flag"></i>禁用
					</button>
		 			<button class="btn btn-white ajax-post" url="{:U("Article/move")}"  target-form="ids">
						<i class="fa fa-exchange"></i>移动
					</button>
					<button class="btn btn-white ajax-post" url="{:U("Article/copy")}" target-form="ids">
						<i class="fa fa-files-o"></i>复制
					</button>  
					<button class="btn btn-white ajax-post" url="{:U("Article/paste")}" target-form="ids" hide-data="true" >
						<i class="fa fa-clipboard"></i>粘贴
					</button> 
					<input type="hidden" class="hide-data" name="cate_id" value="{$cate_id}"/>
					<input type="hidden" class="hide-data" name="pid" value="{$pid}"/>
					<button class="btn btn-white ajax-post confirm" url="{:U("Article/setStatus",array("status"=>-1))}" target-form="ids" >
						<i class="text-danger fa fa-trash"></i>删除
					</button>    
					<!-- <button class="btn document_add" url="{:U('article/batchOperate',array('cate_id'=>$cate_id,'pid'=>I('pid',0)))}">导入</button> -->
					<button class="btn btn-white list_sort" url="{:U('sort',array('cate_id'=>$cate_id,'pid'=>I('pid',0)),'')}" >
						<i class="fa fa-refresh"></i>排序
					</button>
				</span>
            </div>
        </div>
	</div> 
</block>
<block name="body">
	<div class="row     ">
		<div class="col-sm-12 search-form">
			<div class="col-sm-1">
				  <div class="btn-group" id="searchstatus">
	                 <button id="sch-sort-txt" data-toggle="dropdown" class="btn btn-warning dropdown-toggle" data="{$status}">
		                 <if condition="get_status_title($status) eq ''">所有<else/>{:get_status_title($status)}</if>
		                 <span class="caret"></span>
	                 </button>
	                 <ul id="sub-sch-menu"  class="dropdown-menu">
						<li><a href="javascript:;" value="">所有</a></li>
						<li><a href="javascript:;" value="1">正常</a></li>
						<li><a href="javascript:;" value="0">禁用</a></li>
						<li><a href="javascript:;" value="2">待审核</a></li>
	                 </ul>
	             </div>
			</div>
			<div class="col-sm-4">
				<div class="input-daterange input-group">
                    <input type="text" class="form-control" id="time-start" name="time-start"  placeholder="起始时间"/>
                    <span class="input-group-addon">至</span>
                    <input type="text" class="form-control"  id="time-end" name="time-end"  placeholder="结束时间"/>
                </div>
			</div>
			<div class="col-sm-2">
				<div class="input-group">
				<input type="text" class="form-control"  name="nickname" class="text input-2x" value="" placeholder="请输入创建者名字"/>
				</div>
			</div>
			<div class="col-sm-5">
				<div class="input-group">
					<input type="text" class="form-control" name="title" value="{:I('title')}" placeholder="请输入标题文档"> 
					<span class="input-group-btn"> 
						<a id="search" type="button" url="{:U('article/index','pid='.I('pid',0).'&cate_id='.$cate_id,false)}" class="btn btn-primary">
						<i class="fa fa-search green bigger-125"></i>
						</a> 
	                </span>
	            </div>
			</div>
		</div>
	</div>
	<div class="row">
            <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>待审核列表</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="table-responsive">
	                  <table class="table table-striped table-bordered table-hover dataTables-example" >
		                  <thead>
		                  <tr>
							 <th class="row-selected row-selected">
								<label><input type="checkbox" class="check-all" /><span class="lbl"></span></label></th>
			                 <volist name="list_grids" id="field">
			                     <th class="center">{$field.title}</th>
			                 </volist>
		                  </tr>
		                  </thead>
		                  <tbody>
								<volist name="list" id="data">
				                    <tr>
				                        <td><input class="ids" type="checkbox" value="{$data['id']}" name="ids[]"></td>
				                        <volist name="list_grids" id="grid">
				                            <td>{:get_list_field($data,$grid)}</td>
										</volist>
				                    </tr>
				                </volist>
		                  </tbody>
	                  </table>
		            <div class="page pull-right">
				     	{$_page}
			 		</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</block>
<block name="script">
<script type="text/javascript">
$(function(){
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
		var status = $("#sch-sort-txt").attr("data");
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
		if(status != ''){
			query = 'status=' + status + "&" + query;
        }
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});

	/* 状态搜索子菜单 */
 
	$("#sub-sch-menu li").find("a").each(function(){
		$(this).click(function(){
			var text = $(this).text();
			$("#sch-sort-txt").text(text).attr("data",$(this).attr("value"));
		})
	});

	//只有一个模型时，点击新增
	$('.document_add').click(function(){
		var url = $(this).attr('url');
		if(url != undefined && url != ''){
			window.location.href = url;
		}
	});

	//点击排序
	$('.list_sort').click(function(){
		var url = $(this).attr('url');
		var ids = $('.ids:checked');
		var param = '';
		if(ids.length > 0){
			var str = new Array();
			ids.each(function(){
				str.push($(this).val());
			});
			param = str.join(',');
		}

		if(url != undefined && url != ''){
			window.location.href = url + '/ids/' + param;
		}
	});

    //回车自动提交
    $('.search-form').find('input').keyup(function(event){
        if(event.keyCode===13){
            $("#search").click();
        }
    });
 
    $('.input-daterange').datepicker({
    });
})
</script>
</block>
